home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / Q-R / QDPat.cpt / Dialog_2.Pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-10-07  |  3.9 KB  |  111 lines  |  [TEXT/PJMM]

  1. unit Dialog_2;
  2.  
  3. {File name:  Dialog_2.Pas  }
  4. {Function: Handle a dialog}
  5. {History: 10/6/89 Original by Prototyper.   }
  6. {                       }
  7.  
  8.  
  9. interface
  10.  
  11.  
  12.  
  13.     procedure D_Dialog_2;
  14.  
  15. implementation
  16.  
  17.     const                               {These are the item numbers for controls in the Dialog}
  18.         I_OK = 1;
  19.         I_x = 2;
  20.         I_x3 = 3;
  21.         I_x5 = 4;
  22. var 
  23.         ExitDialog : boolean;           {Flag used to exit the Dialog}
  24.         DoubleClick : boolean;          {Flag to say that a double click on a list happened}
  25.         MyPt : Point;                   {Current list selection point}
  26.         MyErr : OSErr;                  {OS error returned}
  27.  
  28.     procedure D_Dialog_2;
  29.         var
  30.             GetSelection : DialogPtr;{Pointer to this dialog}
  31.             tempRect : Rect;            {Temporary rectangle}
  32.             DType : Integer;            {Type of dialog item}
  33.             Index : Integer;            {For looping}
  34.             DItem : Handle;             {Handle to the dialog item}
  35.             CItem, CTempItem : controlhandle;{Control handle}
  36.             sTemp : Str255;             {Get text entered, temp holding}
  37.             itemHit : Integer;          {Get selection}
  38.             temp : Integer;             {Get selection, temp holding}
  39.             dataBounds : Rect;          {Rect to setup the list}
  40.             cSize : Point;              {Pointer to a cell in a list}
  41.             Icon_Handle : Handle;       {Temp handle to read an Icon into}
  42.             NewMouse : Point;           {Mouse location during tracking Icon presses}
  43.             InIcon : boolean;           {Flag to say pressed in an Icon}
  44.             ThisEditText : TEHandle; {Handle to get the Dialogs TE record}
  45.             TheDialogPtr : DialogPeek;{Pointer to Dialogs definition record, contains the TE record}
  46.      
  47.     {This is an update routine for non-controls in the dialog} 
  48.     {This is executed after the dialog is uncovered by an alert} 
  49.     procedure Refresh_Dialog;           {Refresh the dialogs non-controls}
  50.         var 
  51.             rTempRect:Rect;             {Temp rectangle used for drawing}
  52.      
  53.         begin 
  54.             SetPort(GetSelection);      {Point to our dialog window}
  55.             GetDItem(GetSelection,I_OK,DType,DItem,tempRect);{Get the item handle}
  56.             PenSize(3, 3);              {Change pen to draw thick default outline}
  57.             InsetRect(tempRect, -4, -4);{Draw outside the button by 1 pixel}
  58.             FrameRoundRect(tempRect, 16, 16); {Draw the outline}
  59.             PenSize(1, 1);              {Restore the pen size to the default value}
  60.             
  61.     end; 
  62.      
  63.      
  64.     begin                               {Start of dialog handler}
  65.             GetSelection := GetNewDialog(2, nil,  Pointer(-1) );{Bring in the dialog resource}
  66.             ShowWindow(GetSelection);{Open a dialog box}
  67.             SelectWindow(GetSelection);{Lets see it}
  68.             SetPort(GetSelection);      {Prepare to add conditional text}
  69.              
  70.             TheDialogPtr := DialogPeek(GetSelection);{Get to the inner record}
  71.             ThisEditText := TheDialogPtr^.textH;{Get to the TE record}
  72.             HLock(Handle(ThisEditText));{Lock it for safety}
  73.             ThisEditText^^.txSize := 12;{TE Point size}
  74.             TextSize(12);               {Window Point size}
  75.             ThisEditText^^.txFont := systemFont;{TE Font ID}
  76.             TextFont(systemFont);       {Window Font ID}
  77.             ThisEditText^^.txFont := 0;{TE Font ID}
  78.             ThisEditText^^.fontAscent := 12;{Font ascent}
  79.             ThisEditText^^.lineHeight := 12 + 3 + 1;{Font ascent + descent + leading}
  80.             HUnLock(Handle(ThisEditText));{UnLock the handle when done}
  81.             
  82.              
  83.             {Setup initial conditions}
  84.             Refresh_Dialog;             {Draw any Lists, popups, lines, or rectangles}
  85.              
  86.             ExitDialog:=FALSE;          {Do not exit dialog handle loop yet}
  87.              
  88.             repeat                      {Start of dialog handle loop}
  89.                 ModalDialog(nil, itemHit);{Wait until an item is hit}
  90.                 GetDItem(GetSelection, itemHit, DType, DItem, tempRect);{Get item information}
  91.                 CItem := Pointer(DItem);{Get the control handle}
  92.                  
  93.                 {Handle it real time}
  94.                 if (ItemHit =I_OK) then{Handle the Button being pressed}
  95.                 begin
  96.                     {?? Code to handle this button goes here}
  97.                     ExitDialog:=TRUE;{Exit the dialog when this selection is made}
  98.                 end;                    {End for this item selected}
  99.                 
  100.                  
  101.             until ExitDialog;           {Handle dialog items until exit selected}
  102.              
  103.             {Get results after dialog}
  104.             
  105.             DisposDialog(GetSelection);{Flush the dialog out of memory}
  106.             
  107.         end;                            {End of procedure}
  108.     
  109.     end.                                {End of unit}
  110.     
  111.